'    Copyright 2008 Jan Molnar <jan.molnar@abds.de>
'
'    This file is part of JCQ.

'    JCQ is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 2 of the License, or
'    (at your option) any later version.

'    JCQ is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with JCQ. If not, see <http://www.gnu.org/licenses/>.

Imports JCsTools.JCQ.IcqInterface.Interfaces

Public Class IcqMessage
    Implements Interfaces.IMessage

    Private ReadOnly _Attributes As New Hashtable

    Public Sub New()

    End Sub

    Public Sub New(ByVal sender As IContact, ByVal recipient As IContact, ByVal text As String)
        _Attributes("Sender") = sender
        _Attributes("Recipient") = recipient
        _Attributes("Text") = text
    End Sub

    Public ReadOnly Property Attributes() As System.Collections.Hashtable Implements Interfaces.IMessage.Attributes
        Get
            Return _Attributes
        End Get
    End Property

    Public Property Sender() As IContact Implements Interfaces.IMessage.Sender
        Get
            Return DirectCast(_Attributes("Sender"), IContact)
        End Get
        Set(ByVal value As IContact)
            _Attributes("Sender") = value
        End Set
    End Property

    Public Property Recipient() As IContact Implements Interfaces.IMessage.Recipient
        Get
            Return DirectCast(_Attributes("Recipient"), IContact)
        End Get
        Set(ByVal value As IContact)
            _Attributes("Recipient") = value
        End Set
    End Property

    Public Property Text() As String Implements Interfaces.IMessage.Text
        Get
            Return CStr(_Attributes("Text"))
        End Get
        Set(ByVal value As String)
            _Attributes("Text") = value
        End Set
    End Property
End Class

Public Class IcqOfflineMessage
    Inherits IcqMessage

    Public Sub New(ByVal sender As IContact, ByVal recipient As IContact, ByVal text As String, ByVal dateSent As DateTime)
        MyBase.New(sender, recipient, text)
        Attributes("OfflineSentDate") = dateSent
    End Sub

    Public Property OfflineSentDate() As Date
        Get
            Return CDate(Attributes("OfflineSentDate"))
        End Get
        Set(ByVal value As Date)
            Attributes("OfflineSentDate") = value
        End Set
    End Property
End Class